#include <qapplication.h>
#include <qdialog.h>
#include <qpushbutton.h>
#include <qstring.h>
#include <qdebug.h>
#include <QTime>
#include <QLabel>
#include <QMessageBox>

#include "BinaryChromosome.h"
#include "FloatChromosome.h"
#include "Generation.h"
#include "Population.h"
#include "parameters.h"

#include "TestEnvironment.h"
#include "FloatTestEnvironment.h"

#include "TournamentSelectionStrategy.h"
#include "RouletteWheelSelectionStrategy.h"
#include "SimpleSelectionStrategy.h"


int main(int argc, char* argv[])
{
    QApplication app(argc, argv);

    QString str = "";


    BinaryChromosome chromosome(10);
    chromosome.setFitness(2.0);
    chromosome.setRandom();

    BinaryChromosome chrom2(10);
    chrom2.setFitness(5.0);
    chrom2.setRandom();

    chromosome.mutate();

    qDebug() << chromosome;
    qDebug() << chrom2;

    BinaryChromosome chrom3(chrom2);
    qDebug() << chrom3;

    chromosome.crossOver(chrom2);

    qDebug() << chromosome;

    /*FloatChromosome fchr1(10);
    fchr1.setRandom();
    qDebug() << fchr1;
    fchr1.mutate();
    qDebug() << fchr1;

    FloatChromosome fchr2(10);
    fchr2.setRandom();
    qDebug() << fchr2;

    fchr1.crossOver(fchr2);*/
    //Generation generation1(100,10);
    //generation1.addChromosome(chromosome);
    //qDebug() << generation1;




    int selection = Tournament;
    int tournamentSize = 3;

    SelectionStrategy* selectionStrategy;
    switch(selection)
        {
        case Simple:
            selectionStrategy = new SimpleSelectionStrategy();
            qDebug() << "SIMPLE";
            break;
        case RouletteWheel:
            //TODO parameter!!!!!!
            selectionStrategy = new RouletteWheelSelectionStrategy(false);
            qDebug() << "ROULETTE";
            break;
        case Tournament:
            selectionStrategy = new TournamentSelectionStrategy(tournamentSize);
            break;
        default:
            selectionStrategy = new SimpleSelectionStrategy();
            break;
        }



    TestEnvironment environment(5, 20);
    environment.setSelectionStrategy(selectionStrategy);
    environment.setCrossoverProb(0.5);
    environment.setMutationProb(0.1);
    environment.start();
    qDebug() << *environment.getSolution();


    /*FloatTestEnvironment flenv(50, 10);
    flenv.setSelectionStrategy(selectionStrategy);
    flenv.setCrossoverProb(0.5);
    flenv.setMutationProb(0.1);
    flenv.start();
    qDebug() << *flenv.getSolution();*/




    QMessageBox* messageBox = new QMessageBox();
    messageBox->setText(str);
    messageBox->show();

    return 0;//app.exec();
}



